<?php
//网站首页控制器类
class IndexController extends CommonController{
    //动作方法
    public function index(){
    	
		//服装鞋靴，所有分类
		$allClothCate=K('Category')->get_all_data(array('type_id'=>1,'pid'=>0));//顶级分类
		
		foreach ($allClothCate as $k => $v) {	
			$allClothCate[$k]['son']=K('Category')->where(array('pid'=>$v['cid']))->all();	
			$sonId[$k]=K('Category')->get_son_data($v['cid']);
			$sonId[$k][]=$v['cid'];	
		
//			$sonId[]=$v['cid'];
		}
		
//		//箱包类型所有分类
		$allBagCate=K('Category')->get_all_data(array('type_id'=>2,'pid'=>0));
		foreach ($allBagCate as $k => $v) {	
			$allBagCate[$k]['son']=K('Category')->where(array('pid'=>$v['cid']))->all();
			$sonId[$k]=K('Category')->get_son_data($v['cid']);	
			$sonId[$k][]=$v['cid'];
		}
		//类型下所有分类id
		foreach ($sonId as $k => $v) {
			foreach ($v as $key => $value) {
				$sonCateId[]=$value;
			}
			
		}
//		p($sonCateId);die;
		$sonCateId=implode(',', $sonCateId);
		$where=' cid in('.$sonCateId.')';
		
		//类型下所有品牌
		$rand=K('Rand')->where("{$where}")->all();
		$this->assign('rand',$rand);
		
		//类型下所有分类名
		$allClothBag=array_merge($allBagCate,$allClothCate);
		$this->assign('allClothBag',$allClothBag);
		
		//对应楼层8f,服饰鞋包,类型下所有商品
		$where=' category_cid in('.$sonCateId.')';
		$allProduct=K('Product')->where("{$where}")->all();
		$this->assign('allProduct',$allProduct);
		
        //显示视图
        $this->dis('index');
    }
}
